package org.aileen.springioc.demo.controller;

import jakarta.annotation.Resource;
import org.aileen.springioc.demo.model.UserInfo;
import org.aileen.springioc.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//@ResponseBody
@Controller
public class UserController {

    //属性注入:
    @Autowired//将值注入带userService这个属性里面
    private UserService userService;

    //@Qualifier("o2")
   // @Resource(name = "userInfo2")
    //@Autowired

    private UserInfo userInfo;

//    //Setter方法注入
//    @Autowired
//    private UserService userService;
//
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

//    //构造方法注入
//    private UserService userService;
//
//    public UserController() {
//    }
//
//    @Autowired
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }

    public  void sayHi(){
        System.out.println("Hi,UserController...");
        userService.sayHi();
        System.out.println(userInfo);
    }
}
